package cn.jszx.core.query;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * Created by karakapi on 15-9-16.
 */
public class TestQuery extends BaseQuery {
    private String name;
    private Long number;
    private Date date;

    /**
     * 排序列表字段
     **/
    private List<OrderField> orderFields = new ArrayList<OrderField>();

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Long getNumber() {
        return number;
    }

    public void setNumber(Long number) {
        this.number = number;
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }
    /*****************************************/

    /**
     * 设置排序按属性：name
     *
     * @param isAsc 是否升序，否则为降序
     */
    public TestQuery orderbyName(boolean isAsc) {
        orderFields.add(new OrderField("name", isAsc ? "ASC" : "DESC"));
        return this;
    }

    /**
     * 设置排序按属性：number
     *
     * @param isAsc 是否升序，否则为降序
     */
    public TestQuery orderbyNumber(boolean isAsc) {
        orderFields.add(new OrderField("number", isAsc ? "ASC" : "DESC"));
        return this;
    }

    /**
     * 设置排序按属性：date
     *
     * @param isAsc 是否升序，否则为降序
     */
    public TestQuery orderbyDate(boolean isAsc) {
        orderFields.add(new OrderField("date", isAsc ? "ASC" : "DESC"));
        return this;
    }
/****************************************/
    /**
     * ==============================批量查询时的Order条件顺序设置==========================
     * ========
     **/
    public class OrderField {
        private String fieldName;
        private String order;

        public OrderField(String fieldName, String order) {
            super();
            this.fieldName = fieldName;
            this.order = order;
        }
    }
}
